﻿using UnityEngine;

public class PlayerMoveController : MonoBehaviour {

	private CharacterController2D cc;

	private float runSpeed = 40;
	private float move = 0f;
	private bool jump = false;
	private bool crouch = false;

	private void Awake() {
		cc = GetComponent<CharacterController2D>();
	}

	// Update is called once per frame
	void Update() {

		move = Input.GetAxisRaw("Horizontal");

		if (Input.GetButtonDown("Jump")) {
			jump = true;
		}

		if (Input.GetButtonDown("Crouch")) {
			crouch = true;
		} else if (Input.GetButtonUp("Crouch")) {
			crouch = false;
		}

	}

	private void FixedUpdate() {
		Debug.Log("crouch:" + crouch);
		Debug.Log("jump:" + jump);
		cc.Move(move * runSpeed * Time.fixedDeltaTime, crouch, jump);
		jump = false;

	}

}
